package com.toe.forum.webapi.app;

import com.toe.forum.service.ForumArticleService;
import com.toe.forum.service.ISearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CashPreLoad implements ApplicationRunner {

    @Autowired
    private ForumArticleService service;

    @Autowired
    private ISearchService searchService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        System.out.println("CachePreLoad.run()");
        log.debug("准备执行缓存预热");
        service.prepareLoad();
        searchService.loadArticle();
        log.debug("缓存预热执行结束");
    }
}
